Skip to content

[OpenVINO backend] Implements extract_sequences and erfinv in the math suite#22320

Open
goyaladitya05 wants to merge 1 commit intokeras-team:masterfrom
goyaladitya05:openvino/implement-math-logdet-solve
Open

[OpenVINO backend] Implements extract_sequences and erfinv in the math suite#22320
goyaladitya05 wants to merge 1 commit intokeras-team:masterfrom
goyaladitya05:openvino/implement-math-logdet-solve

Conversation

@goyaladitya05
Copy link
Contributor

@goyaladitya05 goyaladitya05 commented Mar 1, 2026

This PR implements the following ops for the math suite of the OpenVINO backend.

  • extract_sequences using a gather based sliding window approach.
  • erfinv via Winitzki approximation + one Newton-Raphson refinement step using the native erf op
  • Removed relevent tests from excluded_concrete_tests.txt

Closes: openvinotoolkit/openvino/issues/34412

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the OpenVINO backend's mathematical capabilities by adding support for several key operations: extract_sequences, erfinv, and math.solve. These additions allow for more complex numerical computations to be performed efficiently using OpenVINO, thereby improving the backend's overall functionality and compatibility with Keras's math suite. The implementation details involve using native OpenVINO operations for sequence extraction and a robust approximation method for the inverse error function, while solve is delegated to an existing linear algebra function.

Highlights

  • New Math Operations: Implemented extract_sequences, erfinv, and math.solve for the OpenVINO backend, expanding the range of supported mathematical computations.
  • extract_sequences Implementation: The extract_sequences operation was implemented using a gather-based sliding-window approach with OpenVINO operations.
  • erfinv Implementation: The erfinv (inverse error function) was implemented using the Winitzki approximation combined with a single Newton-Raphson refinement step, leveraging the native erf operation.
  • math.solve Delegation: The math.solve function now delegates its implementation to the already existing linalg.solve function within the OpenVINO backend.
  • Test Unblocking: Removed previously excluded tests for extract_sequences and erfinv from excluded_concrete_tests.txt, indicating these operations are now functional and tested.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • keras/src/backend/openvino/excluded_concrete_tests.txt
    • Removed ExtractSequencesOpTest::test_extract_sequences_call from the exclusion list.
    • Removed MathOpsCorrectnessTest::test_erfinv_operation_basic from the exclusion list.
    • Removed MathOpsCorrectnessTest::test_erfinv_operation_dtype from the exclusion list.
    • Removed MathOpsCorrectnessTest::test_erfinv_operation_edge_cases from the exclusion list.
    • Removed MathOpsCorrectnessTest::test_extract_sequences from the exclusion list.
  • keras/src/backend/openvino/math.py
    • Implemented the extract_sequences function using OpenVINO ops for shape manipulation, indexing, and gathering.
    • Implemented the erfinv function using a Winitzki approximation and Newton-Raphson refinement.
    • Implemented the solve function by importing and delegating to linalg.solve.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements extract_sequences, erfinv, and solve for the OpenVINO backend. No security vulnerabilities were found. The implementations are functionally correct, and suggestions have been provided to improve the readability and maintainability of extract_sequences and erfinv by refactoring them to use more constants and intermediate variables.

@codecov-commenter
Copy link

codecov-commenter commented Mar 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.96%. Comparing base (95e74a9) to head (43476d7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #22320      +/-   ##
==========================================
+ Coverage   82.95%   82.96%   +0.01%     
==========================================
  Files         595      595              
  Lines       66040    66087      +47     
  Branches    10305    10305              
==========================================
+ Hits        54785    54832      +47     
  Misses       8639     8639              
  Partials     2616     2616              
Flag Coverage Δ
keras 82.79% <100.00%> (+0.01%) ⬆️
keras-jax 60.79% <0.00%> (-0.05%) ⬇️
keras-numpy 54.99% <0.00%> (-0.04%) ⬇️
keras-openvino 49.15% <100.00%> (+0.04%) ⬆️
keras-tensorflow 62.02% <0.00%> (-0.05%) ⬇️
keras-torch 60.83% <0.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@goyaladitya05 goyaladitya05 force-pushed the openvino/implement-math-logdet-solve branch 3 times, most recently from df9f1ef to 9a1384f Compare March 1, 2026 15:36
@goyaladitya05 goyaladitya05 marked this pull request as draft March 4, 2026 03:26
@goyaladitya05 goyaladitya05 force-pushed the openvino/implement-math-logdet-solve branch 2 times, most recently from 9f2704c to 5c7dcc9 Compare March 5, 2026 04:25
@goyaladitya05 goyaladitya05 changed the title [OpenVINO backend] Implements extract_sequences, erfinv, and solve in the math suite [OpenVINO backend] Implements extract_sequences and erfinv in the math suite Mar 5, 2026
@goyaladitya05
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements extract_sequences and erfinv for the OpenVINO backend. The implementation for extract_sequences uses a gather-based sliding window approach, and erfinv is implemented using the Winitzki approximation with a Newton-Raphson refinement step. The changes look correct and enable more math operations on this backend. I've added a couple of suggestions to improve the readability of the new implementations, which are quite dense due to the nature of the OpenVINO Python API.

@goyaladitya05 goyaladitya05 marked this pull request as ready for review March 5, 2026 04:39
@goyaladitya05 goyaladitya05 force-pushed the openvino/implement-math-logdet-solve branch from e23fa27 to eb89f19 Compare March 5, 2026 04:43
…uite.

extract_sequences using a gather based sliding window approach.
erfinv via Winitzki approximation + one Newton-Raphson refinement step using the native erf op
Removed relevent tests from excluded_concrete_tests.txt
@goyaladitya05 goyaladitya05 force-pushed the openvino/implement-math-logdet-solve branch from eb89f19 to 43476d7 Compare March 5, 2026 04:46
@goyaladitya05
Copy link
Contributor Author

This PR is ready for review. I've rebased, and all tests are passing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Keras 3 OpenVINO backend]: Implement support for extract_sequences, erfinv operations

3 participants